# 指定目录路径
import os

root_dir = '/Users/dealthknight/Downloads/yolov5-master/runs/detect'

folders = [d for d in os.listdir(root_dir) if
           os.path.isdir(os.path.join(root_dir, d)) and d.startswith('exp')]
# # 获取文件夹数量
folder_count = len(folders)
print(folder_count)

# # # 加载 YOLO 模型
# ROOT = Path()
# model = YOLO(ROOT / "yolov5s.pt")
# 构建视频文件路径
video_path = f'{root_dir}/exp{folder_count}/0.mp4'
video_path_new = f'{root_dir}/exp{folder_count}/output0.mp4'
return_code = os.system('./ffmpeg -i ' + video_path + ' -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k ' +  video_path_new + '')
print(f"命令执行返回码: {return_code}")
